<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/public/inc/tags.jsp"%>
<input type="hidden" value="${model.id}" name="id">
<input type="hidden" value="${model.bookid}" name="bookid">
<%--<input type="hidden" value="${model.sort}" name="sort">--%>
<div class="form-horizontal">

    <%--书籍部分--%>
    <div class="form-group">
        <label class="control-label col-md-2">书籍名称</label>
        <div class="col-md-10">
            <input id="bookname" name="bookname" class="form-control" placeholder="请输入书籍名称"
                   value="${model.bookname}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">统计参考值</label>
        <div class="col-md-10">
            <input type="text" id="reference_click_count" name="reference_click_count" class="form-control" placeholder="请输入统计参考值"
                   value="${model.reference_click_count}"/>
        </div>
    </div>
    <%--书籍分类部分--%>
    <div class="form-group">
        <label class="control-label col-md-2">一级分类</label>
        <div class="col-md-10">
            <select name="pid" class="form-control" onchange="getmodule()" id="firstClass">
                <option value="3">请选择</option>
                <c:forEach items="${requestScope.classifyListOne}" var="clo" >
                    <option value="${clo.id}"> ${clo.name} </option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">二级分类</label>
        <div class="col-md-10">

            <select name="twoId" class="form-control" id="twoClass">
                <option value="3">请选择</option>
                <c:if test="${not empty requestScope.classifyInfo}">
                    <option value="${requestScope.classifyInfo.id}" selected="selected">${requestScope.classifyInfo.name}</option>
                </c:if>
                <c:forEach items="${requestScope.classifyListTwo}" var="clt" >
                    <option value="${clt.id}" <c:if test="${classifyInfo.pid==clt.pid}"> selected="selected"</c:if>> ${clt.name} </option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">上传书籍图片</label>
        <div class="col-md-10">
            <input type="hidden" name="bookimg" value="${model.bookimg}"/>
            <input type="file" class="btn btn-primary" id="bookimg" name="BookImg"/>
            <img src="http://img.readerday.com/cover/${model.bookimg}" class="thumbnail" style="height: 200px;
            <c:if test="${model.bookimg==null}">display: none;</c:if> ">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">书籍作者</label>
        <div class="col-md-10">
            <input type="text" id="bookauthor" name="bookauthor" class="form-control" placeholder="请输入书籍作者"
                   value="${model.bookauthor}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">书籍出版社</label>
        <div class="col-md-10">
            <input type="text" id="bookpublish" name="bookpublish" class="form-control" placeholder="请输入书籍出版社"
                   value="${model.bookpublish}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">一句话介绍</label>
        <div class="col-md-10">
            <input type="text" id="bookrecommend" name="bookrecommend" class="form-control" placeholder="请输入一句话介绍"
                   value="${model.bookrecommend}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">推荐语</label>
        <div class="col-md-10">
            <input type="text" id="contentsummary" name="contentsummary" class="form-control" placeholder="请输入推荐语"
                   value="${model.contentsummary}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">书籍现价</label>
        <div class="col-md-10">
            <input type="text" id="bookprice" name="bookprice" class="form-control" placeholder="请输入书籍现价"
                   value="${model.bookprice}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">书籍原价</label>
        <div class="col-md-10">
            <input type="text" id="bookoriginalprice" name="bookoriginalprice" class="form-control" placeholder="请输入书籍原价"
                   value="${model.bookoriginalprice}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">书籍字数描述</label>
        <div class="col-md-10">
            <input type="text" id="bookwrodnumber" name="bookwrodnumber" class="form-control" placeholder="请输入书籍字数描述"
                   value="${model.bookwrodnumber}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">音频时长</label>
        <div class="col-md-10">
            <input type="text" id="videoduration" name="videoduration" class="form-control" placeholder="请输入音频时长"
                   value="${model.videoduration}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">活动</label>
        <div class="col-md-10">
            <select name="book_activity" class="form-control">
                <option value="0">请选择</option>
                <option value="0" <c:if test="${model.book_activity==0}"> selected="selected"</c:if>>正常</option>
                <option value="1" <c:if test="${model.book_activity==1}"> selected="selected"</c:if>>上新</option>
                <option value="2" <c:if test="${model.book_activity==2}"> selected="selected"</c:if>>限免</option>
                <option value="3" <c:if test="${model.book_activity==3}"> selected="selected"</c:if>>折扣</option>
                <option value="4" <c:if test="${model.book_activity==4}"> selected="selected"</c:if>>热销</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">活动结束时间</label>
        <div class="col-md-10">
            <fmt:formatDate value="${model.book_activity_end_time}" pattern="yyyy-MM-dd HH:mm:ss" var="end_time"/>
            <input type="text" readonly="readonly" id="book_activity_end_time" name="book_activity_end_time"
                   class="form-control" placeholder="请输入活动结束时间"
                   value="${end_time}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">横幅</label>
        <div class="col-md-10">
            <input type="hidden" name="banner" value="${model.banner}"/>
            <input type="file" class="btn btn-primary" name="BannerImg"/>
            <img src="http://img.readerday.com/cover/${model.banner}" class="thumbnail" style="height: 200px;
            <c:if test="${model.banner==null}">display: none;</c:if> ">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">小课详情图片</label>
        <div class="col-md-10">
            <input type="hidden" name="smallLessonImg" value="${model.smallLessonImg}"/>
            <input type="file" class="btn btn-primary" name="SmallLessonImage"/>
            <img src="http://img.readerday.com/cover/${model.smallLessonImg}" class="thumbnail" style="height: 200px;
            <c:if test="${model.smallLessonImg==null}">display: none;</c:if> ">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">上传思维导图</label>
        <div class="col-md-10">
            <input type="hidden" name="mapping_img" value="${model.mapping_img}"/>
            <input type="file" class="btn btn-primary" id="mapping_img" name="MappingImg"/>
            <img src="http://img.readerday.com/cover/${model.mapping_img}" class="thumbnail" style="height: 200px;
            <c:if test="${model.mapping_img==null}">display: none;</c:if> ">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">上传思维导图(小图)</label>
        <div class="col-md-10">
            <input type="hidden" name="mapping_small_img" value="${model.mapping_small_img}"/>
            <input type="file" class="btn btn-primary" id="mapping_small_img" name="MappingSmallImg"/>
            <img src="http://img.readerday.com/cover/${model.mapping_small_img}" class="thumbnail" style="height: 200px;
            <c:if test="${model.mapping_small_img==null}">display: none;</c:if> ">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">首页显示</label>
        <div class="col-md-10">
            <select name="ishost" class="form-control">
                <option value="0">请选择</option>
                <option value="0" <c:if test="${model.ishost==0}"> selected="selected"</c:if>>否</option>
                <option value="1" <c:if test="${model.ishost==1}"> selected="selected"</c:if>>是</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">类型</label>
        <div class="col-md-10">
            <label>
                <select name="type" class="form-control">
                    <option value="0">请选择</option>
                    <option value="0" <c:if test="${model.type==0}"> selected="selected"</c:if>>书籍</option>
                    <option value="1" <c:if test="${model.type==1}"> selected="selected"</c:if>>小课</option>
                </select>
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">状态</label>
        <div class="col-md-10">
            <label>
                <select name="status" class="form-control">
                    <option value="0">请选择</option>
                    <option value="0" <c:if test="${model.status==0}"> selected="selected"</c:if>>上线</option>
                    <option value="1" <c:if test="${model.status==1}"> selected="selected"</c:if>>下线</option>
                </select>
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">排序</label>
        <div class="col-md-10">
            <input type="text" id="sort" name="sort" class="form-control" placeholder="排序"
                   value="${model.sort}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">撰稿人</label>
        <div class="col-md-10">
            <input type="text" id="copywriter" name="copywriter" class="form-control" placeholder="请输入撰稿人"
                   value="${model.copywriter}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">音频转述师</label>
        <div class="col-md-10">
            <input type="text" id="videoauthorid" name="videoauthorid" class="form-control" placeholder="请输入音频转述师"
                   value="${model.videoauthorid}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">章节数量</label>
        <div class="col-md-10">
            <input type="text" id="chaptercount" name="chaptercount" class="form-control" placeholder="请输入章节数量"
                   value="${model.chaptercount}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">内容简介</label>
        <div class="col-md-10">
            <label>
                <textarea id="content" name="content" style="width:100%;height: 100px">${model.content}</textarea>
            </label>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <button type="submit" class="btn btn-primary">
            <i class="fa fa-floppy-o"></i> 保存
        </button>
    </div>
</div>
<jsp:include page="/public/inc/ueditor.jsp"/>
<script type="text/javascript">
    $(document).ready(function () {
        UE.getEditor('content');

        $('#book_activity_end_time').datetimepicker({
            language: "zh-CN",
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true,
            startView: 'month',
            todayHighlight: true,
            showMeridian: true,
            todayBtn: true
        });

        $("#form1").bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                copywriter: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },
                        regexp: {
                            regexp: /^\+?(0|[1-9][0-9]*)$/,
                            message: '非负整数'
                        }
                    }
                }, type: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }, regexp: {
                            regexp: /^[0-1]*$/,
                            message: '必须选择其中的一个'
                        }
                    }
                }, chaptercount: {
                    validators: {
                        regexp: {
                            regexp: /^[1-9]\d*$/,
                            message: '非0正整数'
                        }
                    }
                }, bookname: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                }, bookauthor: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                }, videoauthorid: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                }, bookprice: {
                    validators: {
                        regexp: {
                            regexp: /^(([1-9]\d*)|0)(\.\d{1,2})?$/,
                            message: '只能输入不超过两位小数的正实数'
                        }
                    }
                }
            }
        });
    });
    //二级联动
    function getmodule() {
        var pid=$("#firstClass").val();
        var obj=document.getElementById("twoClass");
        $.ajax({
            type : 'GET',
            contentType : 'application/json',
            url : '/api/v2/system/wwdx_book_classify/listTwo?pid='+pid,
            dataType : 'json',
            success : function(data) {
                obj.options.length=0;
                $.each(data,function(i,item) {
                    obj.options.add(new Option(item.name,item.id));
                });
            }
        });
    }
    console.log("${requestScope.classifyInfo}")
</script>